home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / 92052tar.gz / 920528.tar / mbuf.h < prev    next >
C/C++ Source or Header  |  1992-05-28  |  2KB  |  72 lines

  1. /* @(#) $Header: mbuf.h,v 1.6 92/05/28 13:50:23 deyke Exp $ */
  2.  
  3. #ifndef _MBUF_H
  4. #define _MBUF_H
  5.  
  6. #include <stdio.h>
  7.  
  8. #ifndef _GLOBAL_H
  9. #include "global.h"
  10. #endif
  11.  
  12. extern long Pushdowns;          /* Total calls to pushdown() */
  13. extern long Pushalloc;          /* Calls to pushdown that call malloc() */
  14.  
  15. /* Basic message buffer structure */
  16. struct mbuf {
  17.     struct mbuf *next;      /* Links mbufs belonging to single packets */
  18.     struct mbuf *anext;     /* Links packets on queues */
  19.     int16 size;             /* Size of associated data buffer */
  20.     int refcnt;             /* Reference count */
  21.     struct mbuf *dup;       /* Pointer to duplicated mbuf */
  22.     char *data;             /* Active working pointers */
  23.     int16 cnt;
  24. };
  25. #define NULLBUF (struct mbuf *)0
  26. #define NULLBUFP (struct mbuf **)0
  27.  
  28. #define PULLCHAR(bpp)\
  29.  ((bpp) != NULL && (*bpp) != NULLBUF && (*bpp)->cnt > 1 ? \
  30.  ((*bpp)->cnt--,(unsigned char)*(*bpp)->data++) : pullchar(bpp))
  31.  
  32. /* In mbuf.c: */
  33. struct mbuf *alloc_mbuf __ARGS((int size));
  34. struct mbuf *free_mbuf __ARGS((struct mbuf *bp));
  35.  
  36. struct mbuf *ambufw __ARGS((int size));
  37. struct mbuf *copy_p __ARGS((struct mbuf *bp,int cnt));
  38. int16 dup_p __ARGS((struct mbuf **hp,struct mbuf *bp,int offset,int cnt));
  39. struct mbuf *free_p __ARGS((struct mbuf *bp));
  40. int16 len_p __ARGS((struct mbuf *bp));
  41. void trim_mbuf __ARGS((struct mbuf **bpp,int length));
  42. int write_p __ARGS((FILE *fp,struct mbuf *bp));
  43.  
  44. struct mbuf *dequeue __ARGS((struct mbuf **q));
  45. void enqueue __ARGS((struct mbuf **q,struct mbuf *bp));
  46. void free_q __ARGS((struct mbuf **q));
  47. int16 len_q __ARGS((struct mbuf *bp));
  48.  
  49. struct mbuf *qdata __ARGS((char *data,int cnt));
  50. int16 dqdata __ARGS((struct mbuf *bp,char *buf,unsigned cnt));
  51.  
  52. void append __ARGS((struct mbuf **bph,struct mbuf *bp));
  53. struct mbuf *pushdown __ARGS((struct mbuf *bp,int size));
  54. int16 pullup __ARGS((struct mbuf **bph,char *buf,int cnt));
  55.  
  56. int pullchar __ARGS((struct mbuf **bpp));       /* returns -1 if nothing */
  57. long pull16 __ARGS((struct mbuf **bpp));        /* returns -1 if nothing */
  58. int32 pull32 __ARGS((struct mbuf **bpp));       /* returns  0 if nothing */
  59.  
  60. int16 get16 __ARGS((char *cp));
  61. int32 get32 __ARGS((char *cp));
  62. char *put16 __ARGS((char *cp,int x));
  63. char *put32 __ARGS((char *cp,int32 x));
  64.  
  65. void iqstat __ARGS((void));
  66. void refiq __ARGS((void));
  67. void mbuf_crunch __ARGS((struct mbuf **bpp));
  68.  
  69. #define AUDIT(bp)       audit(bp,__FILE__,__LINE__)
  70.  
  71. #endif  /* _MBUF_H */
  72.